package org.hhgzs.modules.erp.controller;


import io.swagger.annotations.Api;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.hhgzs.modules.erp.constants.BusinessConstants;
import org.hhgzs.modules.erp.entity.DepotHead;
import org.hhgzs.modules.erp.entity.Sequence;
import org.hhgzs.modules.erp.service.DepotHeadService;
import org.hhgzs.modules.erp.service.SequenceService;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.base.controller.JeecgController;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;

/**
 * <p>
 * 单据编号表 前端控制器
 * </p>
 *
 * @author peiqy
 * @since 2021-07-14
 */
@RestController
@RequestMapping("/sequence")
@Slf4j
@RequiredArgsConstructor
@Api("结算账户管理")
public class SequenceController extends JeecgController<Sequence, SequenceService> {

    private final SequenceService sequenceService;


    /**
     * 单据编号生成接口
     *
     * @param request
     * @return
     */
    @GetMapping(value = "/buildNumber")
    public Result buildNumber(HttpServletRequest request) throws Exception {
        Map<String, Object> map = new HashMap<String, Object>();
        try {
            String number = sequenceService.buildOnlyNumber(BusinessConstants.DEPOT_NUMBER_SEQ);
            map.put("defaultNumber", number);
            return Result.OK(number);
        } catch (Exception e) {
            e.printStackTrace();
            return Result.error("获取数据失败");
        }
    }

}
